package Controller;

import Service.MyMessageService;
import model.MyMessageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("message1")
@RestController
public class MyControlller {
    @Autowired
    MyMessageService myMessageService;

    //填写信息
    @RequestMapping("publish1")
    public Boolean publish(MyMessageInfo myMessageInfo){
        if (!StringUtils.hasLength(myMessageInfo.getFrom())
                || !StringUtils.hasLength(myMessageInfo.getTo())
                || !StringUtils.hasLength(myMessageInfo.getMessage())){
            return false;
        }
        else{
myMessageService.publish(myMessageInfo);
            return true;
        }
    }
}
